package ge.modules.drawables;

import ge.exceptions.FunctionNonSuported;
import ge.lowlevel.DrawEngine;

public class CircleModule extends DrawableObject {

	private double radius;
	private Color c;
	/**
	 *  Draws a circle
	 * @param radius Radius of the circle
	 */
	public CircleModule(double radius) 
	{
		super(2*radius, 2*radius);
		this.radius = radius;
	}
	/**
	 *  Set the pos of the center of the circle
	 *  @param x X position
	 *  @param y Y position
	 */
	public void setCenterPos(double x, double y)
	{
		super.setPos(x, y);
	}
	/**
	 *  Set the pos of the up-left corner of the circle
	 *  @param x X position
	 *  @param y Y position
	 */
	@Override
	public void setPos(double x, double y) {
		 
		super.setPos(x-radius, y-radius);
	}
	/**
	 *  
	 * @param c Color of the circle
	 */
	public void setColor(Color c)
	{
		this.c = c;
	}
	/**
	 * 
	 * @return The actual color
	 */
	public Color getColor()
	{
		return c;
	}
	@Override
	public void draw()
	{

		if(!isVisible())
			return;
		if(!isInsideScreen())
			return;
		
		try
		{
			DrawEngine.get().setLayer(layer);
			if(!c.isBlack())
					DrawEngine.get().setColor(c.getR(), c.getG(), c.getB(), c.getA());
				DrawEngine.get().drawCircle(getRelativeX()+radius, getRelativeY()+radius, radius);
				DrawEngine.get().fill();
			if(!c.isBlack())
				DrawEngine.get().setColor(0,0,0);
		}
		catch (FunctionNonSuported e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
